package com.xqiapp;

import com.xqiapp.bean.Datax;
import com.xqiapp.service.IRoleService;
import com.xqiapp.service.impl.RoleService;
import org.apache.log4j.Logger;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.CountDownLatch;

@SpringBootApplication
@MapperScan(basePackages = "com.xqiapp.mapper")
public class WebxApiServerMulApplication {

	private static final Logger LOG = Logger.getLogger(WebxApiServerMulApplication.class);

	@Bean
	public CountDownLatch closeLatch() {
		return new CountDownLatch(10);
	}

	public static void main(String[] args) throws InterruptedException {
		ApplicationContext ctx = SpringApplication.run(WebxApiServerMulApplication.class, args);
		LOG.info("项目启动!");

		IRoleService roleService = (IRoleService) ctx.getBean("roleService");
		Datax data = new Datax();
		roleService.addRole(data);

		roleService.addRole1(data);

		roleService.addRole2(data);

		CountDownLatch closeLatch = ctx.getBean(CountDownLatch.class);
		closeLatch.await();
	}
}
